import { Modal } from 'antd'
import React from 'react'

interface CommonDialogProps {
    open: boolean
    title?: React.ReactNode
    content?: React.ReactNode
    confirmLoading?: boolean
    width?: number | string
    onOk?: () => void | Promise<void>
    onCancel?: () => void
    okButtonProps?: any
    children?: React.ReactNode
}

const CommonDialog: React.FC<CommonDialogProps> = ({
    open,
    title = 'Title',
    content,
    confirmLoading = true,
    onOk,
    onCancel,
    okButtonProps,
    children,
    width,
}) => (
    <Modal
        title={title}
        open={open}
        onOk={onOk}
        width={width}
        confirmLoading={confirmLoading}
        onCancel={onCancel}
        okButtonProps={okButtonProps}
    >
        {children ?? <div>{content}</div>}
    </Modal>
)

export default CommonDialog
